//
//  ViewController.m
//  11203country
//
//  Created by 小白 on 16/3/3.
//  Copyright © 2016年 小白. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,weak) UITableView *tbView;
@property (nonatomic,copy) NSArray *nameC;
@property (nonatomic,copy) NSArray *imageC;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
//    
//    [[NSArray alloc] initWithObjects:@"A1-南非",@"A2-墨西哥",
//     @"B1-阿根廷",@"B2-尼日利亚",@"C1-英格兰",@"C2-美国",
//     @"D1-德国",@"D2-澳大利亚",@"E1-荷兰",@"E2-丹麦",
//     @"G1-巴西",@"G2-朝鲜",@"H1-西班牙",@"H2-瑞士",nil];
//    
//    [[NSArray alloc] initWithObjects:@"SouthAfrica.png",@"Mexico.png",
//     @"Argentina.png",@"Nigeria.png",@"England.png",@"USA.png",
//     @"Germany.png",@"Australia.png",@"Holland.png",@"Denmark.png",                      @"Brazil.png",@"NorthKorea.png",@"Spain.png",@"Switzerland.png",nil];
    self.nameC =[[NSArray alloc] initWithObjects:@"A1-南非",@"A2-墨西哥",
                         @"B1-阿根廷",@"B2-尼日利亚",@"C1-英格兰",@"C2-美国",
                         @"D1-德国",@"D2-澳大利亚",@"E1-荷兰",@"E2-丹麦",
                         @"G1-巴西",@"G2-朝鲜",@"H1-西班牙",@"H2-瑞士",nil];

    self.imageC = [[NSArray alloc] initWithObjects:@"SouthAfrica.png",@"Mexico.png",
         @"Argentina.png",@"Nigeria.png",@"England.png",@"USA.png",
         @"Germany.png",@"Australia.png",@"Holland.png",@"Denmark.png",                      @"Brazil.png",@"NorthKorea.png",@"Spain.png",@"Switzerland.png",nil];
    UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 22, 320, 545)];
    [self.view addSubview:tableView];
    self.tbView = tableView;
    self.tbView.delegate = self;
    self.tbView.dataSource = self;
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.nameC.count;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //重复利用cell
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
//    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
    cell.textLabel.text = [NSString stringWithFormat:@"%@",self.nameC[indexPath.row]];
    cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",self.imageC[indexPath.row]]];
    
    
    
    return cell;

}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
